﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TonyNet4V1.Control
{
	public class ITemplateCheckBox : ITemplate
	{
		private string strColumnName;
		private DataControlRowType dcrtColumnType;
		private string strControlID;

		public ITemplateCheckBox()
		{
		}

		public ITemplateCheckBox(string strColumnName, DataControlRowType dcrtType)
		{
			this.strColumnName = strColumnName;
			this.dcrtColumnType = dcrtType;
		}

		public ITemplateCheckBox(string strColumnName, DataControlRowType dcrtType, string strControlID)
			:this(strColumnName, dcrtType)
		{
			this.strControlID = strControlID;
		}

		public void InstantiateIn(System.Web.UI.Control ctlContainer)
		{
			switch (dcrtColumnType)
			{
				case DataControlRowType.Header:
					Literal ltr = new Literal();
					ltr.Text = strColumnName;
					ctlContainer.Controls.Add(ltr);
					break;
				case DataControlRowType.DataRow:
					CheckBox cb = new CheckBox();
					cb.ID = strControlID;
					ctlContainer.Controls.Add(cb);
					break;

			}
		}
	}
}